#!/bin/bash


port=6379

if [[ "$1" == "start" ]];then
    netstat -unltp |grep :${port} &> /dev/null
    if [ $? -eq 0 ];then
        echo "redis Already started"
        exit
    fi
    nohup ${install_dir}/${server_dir}/bin/redis-server &> ${log_dir}/${server_dir}/redis.log &
elif [[ "$1" == "stop" ]];then
    netstat -unltp |grep :${port} &> /dev/null
    if [ $? -eq 0 ];then
        pid=`netstat -unltp | grep :${port} | head -1 |awk '{print $7}' | awk -F'/' '{print $1}'`
        kill -9 $pid
    fi
else
    echo "start | stop"
fi